import request from '@/utils/request'
// 审批管理-查询申请列表
export const getApprovalList = data => {
  return request({
    url: `/user/process/instance/${data.page}/${data.pageSize}`,
    method: 'put',
    data
  })
}
// 审批管理-查询审批单的详情数据
export const getInformation = id => {
  return request({
    url: `/user/process/instance/getById/${id}`
  })
}
// 审批管理-
export const getReviewHistory = id => {
  return request({
    url: `/approvals/flows/${id}`
  })
}
export const process = data => {
  return request({
    url: '/approvals/process',
    method: 'post',
    data
  })
}
export const getSetState = params => {
  return request({
    url: '/approvals/setting',
    params
  })
}
// 保存状态
export const saveSetState = data => {
  return request({
    url: '/approvals/setting',
    method: 'put',
    data
  })
}
// 获取流程详情
export const getApprovalsDetail = id => {
  return request({
    url: `/user/process/instance/${id}`
  })
}
// 获取流程详情
export const getApprovalsTaskDetail = id => {
  return request({
    url: `/user/process/instance/tasks/${id}`
  })
}
// 下载图片
export const downImg = picture_id => {
  return request({
    url: `//user/process/buss/showBussImgById/${picture_id}`
  })
}
// 获取流程列表
export const getFlowList = params => {
  return request({ url: `/user/process/definition`, params })
}
export const suspend = params => {
  return request({
    url: `/user/process/suspend/${params.processKey}`,
    params
  })
}
export const startProcess = data => {
  return request({
    url: `/user/process/startProcess`,
    data,
    method: 'post'
  })
}
export const applyeLave = data => {
  return request({
    url: `/user/process_leave/startProcess`,
    data,
    method: 'post'
  })
}

// 驳回
export const approvalsReject = data => {
  return request({
    url: `/user/approvals/${data.id}/reject`,
    method: 'put',
    data
  })
}
// 删除
export const approvalsDel = id => {
  return request({
    url: `/user/approvals/${id}`,
    method: 'delete'
  })
}
// 同意
export const approvalsPass = data => {
  return request({
    url: '/user/process/instance/commit',
    method: 'put',
    data
  })
}
export const applyDimission = data => {
  return request({
    url: '/user/process_dimission/startProcess',
    method: 'post',
    data
  })
}
export const applyOvertime = data => {
  return request({
    url: '/user/process_overtime/startProcess',
    method: 'post',
    data
  })
}
export const exportApprovals = data => {
  return request({
    url: `/approvals/export/${data.month}`,
    data
  })
}

export const updateUser = data => {
  return request({
    url: `/sys/user/${data.id}`,
    method: 'put',
    data
  })
}
